public class test14 {
    class Solution {
        public boolean lemonadeChange(int[] bills) {
            int fiveCount = 0;
            int tenCount = 0;
            for(int bill:bills){
                if(bill==5){
                    fiveCount++;
                }else if(bill==10){
                    if(fiveCount==0){
                        return false;
                    }else{
                        tenCount++;
                        fiveCount--;
                    }
                }else{
                    //先15
                    if(tenCount>0 && fiveCount>0){
                        fiveCount--;
                        tenCount--;
                    }else if(fiveCount>=3){
                        fiveCount -= 3;
                    }else{
                        return false;
                    }
                }
            }
            return true;
        }
    }
}
